/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$(document).ready(function(e){
    //this for the menu
    //    $("#homeSubMenu").show("slow").siblings().hide("slow");
    $('.art-hmenu > li > a').removeClass("active");
    $("#evaluationMenu").addClass("active");
//    $('.gen-menu-ul > li > a > span').removeClass("sub-menu-highlight");
//    $(".gen-menu-ul > li > a > #sendRequest").addClass("sub-menu-highlight");
    
});
function evaluateSubject(subjectID){
    $.ajax({
        type: "POST",
        url: "/TCESystem/category/view~active",
        data: {
            'subjectID':subjectID
        }, // serializes the form's elements.
        success: function(data)
        {
            $("#subjectEvaluationDialog").dialog('open');
            var category="";
            for(var index=0; index < data.categoryList.length; index++){
                category+="<p>"+data.categoryList[index].categoryName+"</p><br/>";
            }
            $("#subjectEvaluationDialog").html(category);
        }
    });
//    $("#subjectEvaluationDialog").html("<img src=\"../images/ajax-loader.gif\" />"+subjectID);
//    $("#subjectEvaluationDialog").dialog('open');
//alert(subjectID);
//    $.getJSON("/TCESystem/category/view~active" ,
//        {
//            //                'borrower.borrowerId': borrowerId
//            },
//            function(json) {
//            $("#subjectEvaluationDialog").dialog('open');
//                $("#subjectEvaluationDialog").html(json.categoryList[0].categoryName);
//            }
//            ); 
}
function serverErrorCheck(param1,param2){
    var message = jQuery.parseJSON(param1.responseText).actionMessages;
    var error = jQuery.parseJSON(param1.responseText).errorMessages;
    if(message.length > 0){
        promptJSONMessage("#messageDialog", jQuery.parseJSON(param1.responseText));
        //return [true,"MESSAGE:"+message,null];
        return true;
    } else if(error.length > 0) {
        return [false,""+error,null];
    } else {
        return [false,"An unkown error had occured",null];
    }                    
}
function deleteErrorCheck(param1,param2){
    var error = jQuery.parseJSON(param1.responseText).errorMessages;
    if(error.length > 0) {
        return [false,""+error];
    }else{
        return [true,"Bingo"];
    }                   
}
function deleteMessageCheck(response, postdata, formid){
//    $("#delmodgridSubjectOffering").dialog('close');
    var message = jQuery.parseJSON(response.responseText).actionMessages;
    if(message.length > 0){
        promptJSONMessage("#messageDialog", jQuery.parseJSON(response.responseText));
    } 
}
datePick = function(elem) {
    $(elem).datepicker({
        dateFormat: 'yy-mm-dd',
        changeMonth: true,
        changeYear: true,
        yearRange: "-100:+10"
    });
    $('#ui-datepicker-div').css("z-index", 2000);
}
function alphanumeric(value, colname) {
    
    var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~";
    for (var i = 0; i < value.length; i++) {
        if (iChars.indexOf(value.charAt(i)) != -1) {
            return [false,colname + ": Please enter non-special characters only"];
        }
    }
    return [true,""];
}